package io.renren.controller;

import io.renren.common.entity.XlsUsersAddressEntity;
import io.renren.service.XlsUsersAddressService;
import io.renren.utils.AppResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;


/**
 * 会员地址表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-04-12
 */
@RestController
@RequestMapping("/api/xlsusersaddress")
@Api(tags="会员地址表")
public class XlsUsersAddressController {
    @Autowired
    private XlsUsersAddressService xlsUsersAddressService;

    /**
     * 获取用户地址
     * @param userId
     * @return
     */
    @PostMapping( "/selectAddressByuserId")
    @ApiOperation(value="获取用户地址")
    public AppResult selectAddressByuserId(Long userId){
        return xlsUsersAddressService.selectAddressByuserId(userId);
    }

    /**
     * 新建收货地址
     */
    @PostMapping( "/createAddress")
    @ApiOperation(value="新增用户地址")
    public AppResult createAddress(XlsUsersAddressEntity usersAddress){
        return xlsUsersAddressService.createAddress(usersAddress);
    }

    /**
     * 修改收货地址
     */
    @PostMapping("/updateAddress")
    @ApiOperation(value="修改收货地址")
    public AppResult updateAddress(XlsUsersAddressEntity usersAddress) {
        return xlsUsersAddressService.updateAddress(usersAddress);
    }

    /**
     * 校验是否是第一个地址
     * @param userId
     * @return
     */
    @RequestMapping("/checkIsFirstAddress")
    @ApiOperation(value="校验是否是第一个地址")
    public AppResult checkIsFirstAddress(Long userId){
        return xlsUsersAddressService.checkIsFirstAddress(userId);
    }

    /**
     * 根据地址id查询用户地址
     * @param id
     * @return
     */
    @PostMapping( "/selectAddressByAddressId")
    @ApiOperation(value="根据地址id查询用户地址")
    public AppResult selectAddressByAddressId(Long id){
        return xlsUsersAddressService.selectAddressByAddressId(id);
    }


}